<?xml version="1.0"?>
<component name="org.nuxeo.search.ui.contentviews.override">

  <require>org.nuxeo.search.ui.contentviews</require>

  <extension point="contentViews" target="org.nuxeo.ecm.platform.ui.web.ContentViewService">

    <contentView name="default_search">
      <title>label.search.default</title>
      <translateTitle>true</translateTitle>
      <showTitle>false</showTitle>
      <emptySentence>label.content.empty.search</emptySentence>
      <translateEmptySentence>true</translateEmptySentence>

      <pageProvider name="default_search">
        <property name="coreSession">#{documentManager}</property>
        <property name="maxResults">DEFAULT_NAVIGATION_RESULTS</property>
      </pageProvider>

      <searchLayout name="default_search_layout"/>
      <waitForExecution>false</waitForExecution>
      <waitForExecutionSentence>
        label.search.waitForExecution
      </waitForExecutionSentence>

      <showPageSizeSelector>true</showPageSizeSelector>
      <useGlobalPageSize>false</useGlobalPageSize>
      <refresh>
        <event>documentChanged</event>
        <event>documentChildrenChanged</event>
      </refresh>
      <cacheKey>only_one_cache</cacheKey>
      <cacheSize>1</cacheSize>

      <resultLayouts>
        <layout iconPath="/icons/document_listing_icon_2_columns_icon.png" name="document_listing_thumbnail" showEditRows="true" showSlideshow="true" title="document_thumbnail_listing" translateTitle="true"/>
        <layout iconPath="/icons/document_listing_icon.png" name="document_listing_table" showCSVExport="true" showEditColumns="true" showSpreadsheet="true" title="document_listing" translateTitle="true"/>
      </resultLayouts>

      <selectionList>CURRENT_SELECTION</selectionList>
      <actions category="CURRENT_SELECTION_LIST"/>

      <resultColumns>
        #{searchDocument.cvd.selectedLayoutColumns}
      </resultColumns>

      <resultLayout>
        #{searchDocument.cvd.resultLayoutName}
      </resultLayout>

      <flags>
        <flag>SEARCH</flag>
      </flags>
    </contentView>

    <contentView name="simple_search">

      <title>label.search.form.simple</title>
      <translateTitle>true</translateTitle>
      <showTitle>false</showTitle>
      <iconPath>/icons/document_listing_icon.png</iconPath>

      <emptySentence>label.content.empty.search</emptySentence>
      <translateEmptySentence>true</translateEmptySentence>

      <pageProvider name="simple_search">
        <property name="coreSession">#{documentManager}</property>
        <property name="maxResults">DEFAULT_NAVIGATION_RESULTS</property>
      </pageProvider>

      <searchLayout name="simple_search_layout"/>
      <waitForExecution>true</waitForExecution>
      <waitForExecutionSentence>
        label.search.waitForExecution
      </waitForExecutionSentence>

      <showPageSizeSelector>true</showPageSizeSelector>
      <useGlobalPageSize>true</useGlobalPageSize>
      <refresh>
        <event>documentChanged</event>
        <event>documentChildrenChanged</event>
      </refresh>
      <cacheKey>only_one_cache</cacheKey>
      <cacheSize>1</cacheSize>

      <resultLayouts>
        <layout iconPath="/icons/document_listing_icon_2_columns_icon.png" name="document_listing_thumbnail" showEditRows="true" showSlideshow="true" title="document_thumbnail_listing" translateTitle="true"/>
        <layout iconPath="/icons/document_listing_icon.png" name="document_listing_table" showCSVExport="true" showEditColumns="true" showSpreadsheet="true" title="document_listing" translateTitle="true"/>
      </resultLayouts>

      <resultColumns>
        #{searchDocument.cvd.selectedLayoutColumns}
      </resultColumns>

      <resultLayout>
        #{searchDocument.cvd.resultLayoutName}
      </resultLayout>

      <selectionList>CURRENT_SELECTION</selectionList>
      <actions category="CURRENT_SELECTION_LIST"/>

    </contentView>

    <contentView name="nxql_search">

      <title>label.search.nxql</title>
      <translateTitle>true</translateTitle>
      <showTitle>false</showTitle>
      <emptySentence>label.content.empty.search</emptySentence>
      <translateEmptySentence>true</translateEmptySentence>

      <pageProvider name="nxql_search">
        <property name="coreSession">#{documentManager}</property>
        <property name="maxResults">DEFAULT_NAVIGATION_RESULTS</property>
        <parameter>#{searchUIActions.nxqlQuery}</parameter>
      </pageProvider>

      <waitForExecution>true</waitForExecution>

      <showPageSizeSelector>true</showPageSizeSelector>
      <useGlobalPageSize>true</useGlobalPageSize>
      <refresh>
        <event>documentChanged</event>
        <event>documentChildrenChanged</event>
      </refresh>
      <cacheKey>only_one_cache</cacheKey>
      <cacheSize>1</cacheSize>

      <resultLayouts>
        <layout iconPath="/icons/document_listing_icon_2_columns_icon.png" name="document_listing_thumbnail" showEditRows="true" showSlideshow="true" title="document_thumbnail_listing" translateTitle="true"/>
        <layout iconPath="/icons/document_listing_icon.png" name="document_listing_table" showCSVExport="true" showEditColumns="true" showSpreadsheet="true" title="document_listing" translateTitle="true"/>
      </resultLayouts>

      <selectionList>CURRENT_SELECTION</selectionList>
      <actions category="CURRENT_SELECTION_LIST"/>

    </contentView>

    <contentView name="all_saved_searches">

      <showTitle>false</showTitle>

      <coreQueryPageProvider>
        <property name="coreSession">#{documentManager}</property>
        <whereClause docType="AdvancedSearch">
          <predicate operator="FULLTEXT" parameter="ecm:fulltext">
            <field name="fulltext_all" schema="advanced_search"/>
          </predicate>
          <predicate operator="FULLTEXT" parameter="dc:title">
            <field name="title" schema="advanced_search"/>
          </predicate>
          <predicate operator="BETWEEN" parameter="dc:modified">
            <field name="modified_min" schema="advanced_search"/>
            <field name="modified_max" schema="advanced_search"/>
          </predicate>
          <fixedPart>
            ecm:mixinType = 'SavedSearch'
            AND cvd:contentViewName IS NOT NULL
            AND ecm:isProxy = 0
            AND ecm:isVersion = 0
            AND ecm:isTrashed = 0
            AND ecm:parentId = ?
            AND SORTED_COLUMN IS NOT NULL
          </fixedPart>
        </whereClause>
        <parameter>#{userWorkspaceManagerActions.currentUserPersonalWorkspace.id}</parameter>
        <sort ascending="true" column="dc:title"/>
        <pageSize>20</pageSize>
      </coreQueryPageProvider>

      <searchLayout filterDisplayType="quick" name="document_content_filter"/>
      <showFilterForm>true</showFilterForm>

      <showPageSizeSelector>true</showPageSizeSelector>
      <useGlobalPageSize>false</useGlobalPageSize>
      <refresh>
        <event>documentChanged</event>
        <event>documentChildrenChanged</event>
        <event>searchSaved</event>
      </refresh>
      <cacheKey>only_one_cache</cacheKey>
      <cacheSize>1</cacheSize>

      <resultLayouts>
        <layout iconPath="/icons/document_listing_icon.png" name="document_listing_table" showCSVExport="true" showEditColumns="true" showSpreadsheet="true" title="document_listing" translateTitle="true"/>
      </resultLayouts>

      <selectionList>SAVED_SEARCHES_CURRENT_SELECTION</selectionList>
      <actions category="SAVED_SEARCHES_CURRENT_SELECTION_LIST"/>
    </contentView>

  </extension>

</component>
